vec2 fixuv(in vec2 uv) {
    vec2 p = 10. * vec2(uv.x / iResolution.x * (iResolution.x / iResolution.y), abs(uv.y / iResolution.y - 1.));
    return p;
}

vec3 drawGrid(in vec2 p) {
    float f = floor(p.x) + floor(p.y);
    vec3 col = mix(vec3(0.75), vec3(0.3), smoothstep(0., 1., mod(f, 2.)));
    return col;
}

// 画中心线
vec3 drawCenterLine(in vec2 p, in vec3 col) {
    p = (2.0 * p - iResolution.xy) / min(iResolution.x, iResolution.y);
    col = mix(col, vec3(1., 0., 0.), smoothstep(abs(p.x), abs(p.x), fwidth(p.x) * 2.));
    col = mix(col, vec3(0., 0., 1.), smoothstep(abs(p.y), abs(p.y), fwidth(p.y) * 2.));
    return col;
}

float sdfCircle(in vec2 p ,in float r){
    return length(p)-r;
}

vec3 drawCircleGrid(in vec2 p,in vec3 col,in vec3 color){

    vec2 pos = fract(p)-vec2(0.5,0.5);
    float d = length(pos)-0.3;
    vec3 co =mix(col, color,smoothstep(0.001,0.,d));
    // col = mix(col,color,fract(d));
    return co;
}

void mainImage(out vec4 fragColor, in vec2 fragCoord) {
    vec2 p = fixuv(fragCoord);
    vec3 col = drawGrid(p);
    // col = drawCenterLine(fragCoord, col);
    col = drawCircleGrid(p,col,vec3(1.,0.,0.));
    fragColor = vec4(col, 1.);
}
